package com.moonlit.myspring;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

/**
 * @Autowired 自动装配信息
 * @Qualifier 如果两个实现类同时实现一个接口，那么可以使用@Q（）来选取你想要的实现
 */

@Component("guanYu")
public class GuanYu implements Hero{

    @Autowired
    @Qualifier("halberd")
    private Weapon weapon;

//    public void setWeapon(Weapon weapon) {
//        this.weapon = weapon;
//    }

    @Override
    public void preform() {
        System.out.println("GuanYu pick up his weapon");
        weapon.attack();
    }
}
